﻿
@{
    Layout = "~/Views/Home/_Layout-Head.cshtml";
}
@using Models.Models;
@using System.Linq;
    <html>
    <head>
        <title></title>
        <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
        <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>

        <!-- 模态框（Modal） -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div id="qqs">
                    <p >正在转发<span id="zmicr" style="color:aqua"></span>的微博</p>
                    <div class="messages" contentEditable='true'></div>
                    <div class="Buts">
                        <img src="~/images/bba_thumb.gif" class='bqs' />
                        <span class='submits'>转发</span>
                        <!--face begin-->
                        <div class="faces">
                            <ul>
                                <li><img src="~/images/smilea_thumb.gif" title="[呵呵]"></li>
                                <li><img src="~/images/tootha_thumb.gif" title="[嘻嘻]"></li>
                                <li><img src="~/images/laugh.gif" title="[哈哈]"></li>
                                <li><img src="~/images/tza_thumb.gif" title="[可爱]"></li>
                                <li><img src="~/images/kl_thumb.gif" title="[可怜]"></li>
                                <li><img src="~/images/kbsa_thumb.gif" title="[挖鼻屎]"></li>
                                <li><img src="~/images/cj_thumb.gif" title="[吃惊]"></li>
                                <li><img src="~/images/shamea_thumb.gif" title="[害羞]"></li>
                                <li><img src="~/images/zy_thumb.gif" title="[挤眼]"></li>
                                <li><img src="~/images/bz_thumb.gif" title="[闭嘴]"></li>
                                <li><img src="~/images/bs2_thumb.gif" title="[鄙视]"></li>
                                <li><img src="~/images/lovea_thumb.gif" title="[爱你]"></li>
                                <li><img src="~/images/sada_thumb.gif" title="[泪]"></li>
                                <li><img src="~/images/heia_thumb.gif" title="[偷笑]"></li>
                                <li><img src="~/images/qq_thumb.gif" title="[亲亲]"></li>
                                <li><img src="~/images/sb_thumb.gif" title="[生病]"></li>
                                <li><img src="~/images/mb_thumb.gif" title="[太开心]"></li>
                                <li><img src="~/images/ldln_thumb.gif" title="[懒得理你]"></li>
                                <li><img src="~/images/yhh_thumb.gif" title="[右哼哼]"></li>
                                <li><img src="~/images/zhh_thumb.gif" title="[左哼哼]"></li>
                                <li><img src="~/images/x_thumb.gif" title="[嘘]"></li>
                                <li><img src="~/images/cry.gif" title="[衰]"></li>
                                <li><img src="~/images/wq_thumb.gif" title="[委屈]"></li>
                                <li><img src="~/images/t_thumb.gif" title="[吐]"></li>
                                <li><img src="~/images/k_thumb.gif" title="[打哈气]"></li>
                                <li><img src="~/images/bba_thumb.gif" title="[抱抱]"></li>
                                <li><img src="~/images/angrya_thumb.gif" title="[怒]"></li>
                                <li><img src="~/images/yw_thumb.gif" title="[疑问]"></li>
                                <li><img src="~/images/cza_thumb.gif" title="[馋嘴]"></li>
                                <li><img src="~/images/88_thumb.gif" title="[拜拜]"></li>
                                <li><img src="~/images/sk_thumb.gif" title="[思考]"></li>
                                <li><img src="~/images/sweata_thumb.gif" title="[汗]"></li>
                                <li><img src="~/images/sleepya_thumb.gif" title="[困]"></li>
                                <li><img src="~/images/sleepa_thumb.gif" title="[睡觉]"></li>
                                <li><img src="~/images/money_thumb.gif" title="[钱]"></li>
                                <li><img src="~/images/sw_thumb.gif" title="[失望]"></li>
                                <li><img src="~/images/cool_thumb.gif" title="[酷]"></li>
                                <li><img src="~/images/hsa_thumb.gif" title="[花心]"></li>
                                <li><img src="~/images/hatea_thumb.gif" title="[哼]"></li>
                                <li><img src="~/images/gza_thumb.gif" title="[鼓掌]"></li>
                                <li><img src="~/images/dizzya_thumb.gif" title="[晕]"></li>
                                <li><img src="~/images/bs_thumb.gif" title="[悲伤]"></li>
                                <li><img src="~/images/crazya_thumb.gif" title="[抓狂]"></li>
                                <li><img src="~/images/h_thumb.gif" title="[黑线]"></li>
                                <li><img src="~/images/yx_thumb.gif" title="[阴险]"></li>
                                <li><img src="~/images/nm_thumb.gif" title="[怒骂]"></li>
                                <li><img src="~/images/hearta_thumb.gif" title="[心]"></li>
                                <li><img src="~/images/unheart.gif" title="[伤心]"></li>
                                <li><img src="~/images/pig.gif" title="[猪头]"></li>
                                <li><img src="~/images/ok_thumb.gif" title="[ok]"></li>
                                <li><img src="~/images/ye_thumb.gif" title="[耶]"></li>
                                <li><img src="~/images/good_thumb.gif" title="[good]"></li>
                                <li><img src="~/images/no_thumb.gif" title="[不要]"></li>
                                <li><img src="~/images/z2_thumb.gif" title="[赞]"></li>
                                <li><img src="~/images/come_thumb.gif" title="[来]"></li>
                                <li><img src="~/images/sad_thumb.gif" title="[弱]"></li>
                                <li><img src="~/images/lazu_thumb.gif" title="[蜡烛]"></li>
                                <li><img src="~/images/clock_thumb.gif" title="[钟]"></li>
                                <li><img src="~/images/cake.gif" title="[蛋糕]"></li>
                                <li><img src="~/images/m_thumb.gif" title="[话筒]"></li>
                                <li><img src="~/images/weijin_thumb.gif" title="[围脖]"></li>
                                <li><img src="~/images/lxhzhuanfa_thumb.gif" title="[转发]"></li>
                                <li><img src="~/images/lxhluguo_thumb.gif" title="[路过这儿]"></li>
                                <li><img src="~/images/bofubianlian_thumb.gif" title="[bofu变脸]"></li>
                                <li><img src="~/images/gbzkun_thumb.gif" title="[gbz困]"></li>
                                <li><img src="~/images/boboshengmenqi_thumb.gif" title="[生闷气]"></li>
                                <li><img src="~/images/chn_buyaoya_thumb.gif" title="[不要啊]"></li>
                                <li><img src="~/images/daxiongleibenxiong_thumb.gif" title="[dx泪奔]"></li>
                                <li><img src="~/images/cat_yunqizhong_thumb.gif" title="[运气中]"></li>
                                <li><img src="~/images/youqian_thumb.gif" title="[有钱]"></li>
                            </ul>
                        </div>
                        <!--face end-->
                    </div>
                </div>
            </div><!-- /.modal -->
        </div>

        <div class="lmlblog-member-main" data="1">
            <div class="lmlblog-member-content">
                <div class="lmlblog-member-content-list clear">
                    <div class="lmlblog-member-right">
                        <!-- 新加入的人	 -->
                        <div class="lmlblog-member-left-visitor clear">
                            <h3>新加入的人</h3>
                            @{
                                var news = ViewData["News"] as List<Information>;
                            }

                            @foreach (var item in news)
                            {
                                <li>
                                    <a href="/Other/OtherIndex/@item.UserID">
                                        <img src="~/picture/@item.Photo" class="avatar" />
                                        <p>@item.Nickname</p>
                                    </a>
                                </li>
                            }
                        </div>
                        <!--TOP  10-->
                        <div class="lmlblog-member-left-profile">
                            <h3>关注度&nbsp;TOP10</h3>
                            @{
                                var k = 1;
                                foreach (var item in ViewData["TOP"] as IEnumerable<IGrouping<string, User_rs>>)
                                {
                                    <li>
                                        @if (k > 3)
                                        {
                                        <span class="lmlblog-mark lmlblog-lv" style="color:aliceblue">TOP &nbsp;@k</span>
                                            <span>@item.Key</span>
                                            <span style="float:right">@item.Count() </span>
                                        }
                                        else
                                        {
                                            <span class="lmlblog-mark lmlblog-vip" style="color:aliceblue">TOP &nbsp;@k</span>
                                            <span>@item.Key</span>
                                            <span style="float:right">@item.Count() </span>
                                        }

                                    </li>
                                    k++;
                                }
                            }

                        </div>
                    </div>
                    <div class="lmlblog-member-left">
                        <div id="show">

                        </div>
                        <!-- 换页 -->
                        <div class="lmlblog-pager">
                            <a class="lmlblog-pager-left" onclick="upppage()">上一页</a>
                            <div class="lmlblog-pager-center layui-form">
                                <div id="index">

                                </div>
                            </div>
                            <a class="lmlblog-pager-right" onclick="lowpage()">下一页</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type='text/javascript' src='~/js/jquery.min.js'></script>
        <script>
        var size = 3;
        var index = 1;
        var sumwb =@ViewBag.SumWB;
        var totalPage = parseInt(sumwb % size == 0 ? sumwb / size : sumwb / size + 1);
        $(function () {
            showpage(size, index);

        });
        function upppage() {
            if (index == 1) {
                return alert("当前页是首页！");
            }
            index = index - 1;
            showpage(size, index);
            $("#index").empty();
            $("#index").append("第" + index + "页");
        };
        function lowpage() {
            if (index == totalPage) {
                return alert("当前已经是最后一页了！");
            }
            index = index + 1;
            showpage(size, index);
            $("#index").empty();
            $("#index").append("第" + index + "页");
        };
          function showpage(size, index) {
                $("#index").empty();
                $("#index").append("第" + index + "页");
            $.ajax({
                type: "get",
                url: "/Home/Getmblog",
                data: { size: size, index: index,},
                success: function (data) {
                    $("#show").empty();
                    var idx = 1;
                    $.each(data, function (key, val) {                      
                        var show;
                        if (val.Fw.length>0) {
                            show = `<div class="lmlblog-post-list">
                            <div class="lmlblog-posts-list words" style="background-color:antiquewhite; background-image:url(/images/058.png); "
                            data="4197">
                            <!-- 动态内容部分，包括列表 -->
                            <div class="lmlblog-post-user-info">
                            <div class="lmlblog-post-user-info-avatar" user-data="1">
                            <a href="/Other/OtherIndex/` + val.UserID + `" style="display: inline-block;">
                            <img src="/picture/` + val.Photo + `" class="avatar" />
                            </a>
                            </div>
                            <div class="lmlblog-post-user-info-name">
                            <a href="/Other/OtherIndex/`+ val.UserID + `">
                            <font style="color:#333;font-weight:600">` + val.Nickname + `</font>
                            </a>
                            </div>
                            <div class="lmlblog-post-user-info-time">` + val.Release_time + `<br>转发来自：`+ val.Fw[0].Nickname + `</div>
                            </div>
                            <!-- 作者信息 -->
                            <div class="lmlblog-post-content">
                            <a class="post_list_link" href="#">` + val.Content + `</a>
                            </div><div class="lmlblog-posts-list words" style=" background-image:url(images/058.png); " data="4197">
                                    <!-- 动态内容部分，包括列表 -->
                                    <div class="lmlblog-post-user-info">
                                        <div class="lmlblog-post-user-info-avatar" user-data="1">
                                            <a href="Other/OtherIndex/`+ val.Fw[0].UserID + `" style="display: inline-block;">
                                                <img src="/picture/` + val.Fw[0].Photo + `" class="avatar"></a></div>
                                            <div class="lmlblog-post-user-info-name">
                                                <a href="Other/OtherIndex/`+ val.Fw.UserID + `">
                                                    <font style="color:#333;font-weight:600">` + val.Fw[0].Nickname + `</font>
                                                </a>
                                            </div>
                                            <div class="lmlblog-post-user-info-time">` + val.Fw[0].Release_time + `</div>
                                        </div>
                                        <!-- 作者信息 -->
                                         <div class="lmlblog-post-content">
                                         <a class="post_list_link" href="#">` + val.Fw[0].Content + `</a></div>
                                            <div class="lmlblog-post-images-list clear">`;
                            if (val.Fw[0].WB_pic != null) {
                                $.each(val.Fw[0].WB_pic, function (key2, img) {
                                    show += `<a href="/images/` + img.URL + `" data-fancybox="gallery"
                                    data-caption='<i class="fa fa-copyright" ></i>  lmlblog' >
                                    <img src="/images/`+ img.URL + `"  width="150" height="200" style=" margin-right:20px" alt="司空琪吧十一月壁纸" /></a>`;
                                })
                            }                                         
                            show += `</div></div ><div class="lmlblog-post-bar">
                            <ul><li>
                            <a  onclick="getmbid(`+ val.MbID + `,` + val.UserID +`)" data-toggle="modal" data-target="#myModal">
                            <img src="/picture/转发.png" width="20" height="20"  />转发 <span>` + val.Forward + `</span>
                            </a>
                            </li>
                            <li>
                            <a onclick="zan(`+ val.MbID + `,` + idx + `)">
                            <img src = "/picture/点赞.png" width = "20" height = "20" /> 点赞 <span id="zan` + idx + `"> ` + val.Likes + `</span></a>
                            </li>
                            <li>
                            <a data-ajax="true" onclick="(downup(`+ idx + `))" id="DownUp` + idx + `" data-ajax-method="get" data-ajax-mode="replace" data-ajax-update="#ShowComm` + idx + `" href="/Home/ShowComm?MbID=` + val.MbID + `">
                            <img src="/picture/评论.png" width="20" height="20" />评论 <span>` + val.Comment.length + `</span>
                             </a>
                            </li>
                            </ul>
                            </div>
                            <div id="ShowComm`+ idx + `"></div >
                            <div class="lmlblog-post-footer-bar">' +
                            <span title="` + val.Release_time + `">` + val.Release_time + `</span>
                            <span>电脑端</span><i class="lmlblog-icon"
                            onclick="lmlblog_post_type_open();">&#xe62c;</i>
                            </div></div></div>`;
                        } else {
                            show = `<div class="lmlblog-post-list">
                            <div class="lmlblog-posts-list words" style="background-image:url(/images/058.png); "
                            data="4197">
                            <!-- 动态内容部分，包括列表 -->
                            <div class="lmlblog-post-user-info">
                            <div class="lmlblog-post-user-info-avatar" user-data="1">
                            <a href="/Other/OtherIndex/` + val.UserID + `" style="display: inline-block;">
                            <img src="/picture/` + val.Photo + `" class="avatar" />
                            </a>
                            </div>
                            <div class="lmlblog-post-user-info-name">
                            <a href="/Other/OtherIndex/`+ val.UserID + `">
                            <font style="color:#333;font-weight:600">` + val.Nickname + `</font>
                            </a>
                            </div>
                            <div class="lmlblog-post-user-info-time">` + val.Release_time + `</div>
                            </div>
                            <!-- 作者信息 -->
                            <div class="lmlblog-post-content">
                            <a class="post_list_link" href="#">` + val.Content + `</a>
                            </div><div class="lmlblog-post-images-list clear">`;
                            if (val.WB_pic != null) {
                                $.each(val.WB_pic, function (key2, img) {
                                    show += `<a href="/images/` + img.URL + `" data-fancybox="gallery"
                                    data-caption='<i class="fa fa-copyright" ></i>  lmlblog' >
                                    <img src="/images/`+ img.URL + `"  width="150" height="200" style="margin-right:20px" alt="司空琪吧十一月壁纸" /></a>`;
                                })
                            }
                            show += `</div ><div class="lmlblog-post-bar">
                            <ul><li>
                            <a  onclick="getmbid(`+ val.MbID + `,`+val.UserID+`)" data-toggle="modal" data-target="#myModal">
                            <img src="/picture/转发.png" width="20" height="20"  />转发 <span>` + val.Forward + `</span>
                            </a>
                            </li>
                            <li>
                            <a onclick="zan(`+ val.MbID + `,` + idx + `)">
                            <img src = "/picture/点赞.png" width = "20" height = "20" /> 点赞 <span id="zan` + idx + `"> ` + val.Likes + `</span></a>
                            </li>
                            <li>
                            <a data-ajax="true" onclick="(downup(`+ idx + `))" id="DownUp` + idx + `" data-ajax-method="get" data-ajax-mode="replace" data-ajax-update="#ShowComm` + idx + `" href="/Home/ShowComm?MbID=` + val.MbID + `">
                            <img src="/picture/评论.png" width="20" height="20" />评论 <span>` + val.Comment.length + `</span>
                             </a>
                            </li>
                            </ul>
                            </div>
                            <div id="ShowComm`+ idx + `"></div >
                            <div class="lmlblog-post-footer-bar">' +
                            <span title="` + val.Release_time + `">` + val.Release_time + `</span>
                            <span>电脑端</span><i class="lmlblog-icon"
                            onclick="lmlblog_post_type_open();">&#xe62c;</i>
                            </div></div></div></div>`;
                        }                       
                        $("#show").append(show);
                        idx = idx + 1;
                    })
                },
                error: function (err) {
                    console.log(err.responseText);
                }
            })
        };
        //点赞
        function zan(Mbid, idx) {
            var dz = $("#zan" + idx);
            $.ajax({
                type: "get",
                url: "/Home/Fabulous?Mbid=" + Mbid,
                success: function (dal) {
                    if (dal == 1) {
                        var za = parseInt(dz.text());

                        dz.empty();
                        dz.text(za + 1);
                    }
                    else if (dal == 0) {
                        var za = parseInt(dz.text());
                        dz.empty();
                        dz.text(za - 1);
                    }
                },
                error: function (err) {
                    console.log(err.responseText);
                }
            })
        };
        var k = 1;
            function downup(idx) {
            if (k%2 == 0) {
                shou(idx);
            } else {
                xian(idx);
            }
        };
            function shou(idx) {
                k = k - 1;
                $("#ShowComm" + idx).empty();
                $("#DownUp" + idx).attr('data-ajax-update', '');
            }
        function xian(idx) {
            k = k + 1;
            $("#DownUp" + idx).attr('data-ajax-update', '#ShowComm' + idx);
        };
        </script>
        <script src="~/js/jquery-1.10.2.min.js"></script>
        @*转发*@
        <script type="text/javascript">
            //点击小图片，显示表情
            $("body").on('click', '.bqs', function (e) {
                $(".faces").slideDown(); //慢慢向下展开
                e.stopPropagation(); //阻止冒泡事件
            });
            //在桌面任意地方点击，关闭表情框
            $("body").on('click', document, function () {
                $(".faces").slideUp(); //慢慢向上收
            });
            //点击小图标时，添加功能
            $("body").on('click', '.faces ul li', function () {
                let simg = $(this).find("img").clone();
                $(".messages").append(simg); //将表情添加到输入框
            });
            //点击发表按扭，转发该条微博
            $("body").on('click', 'span.submits', function () {
                var txt = $(".messages").html(); //获取输入框内容
                if (txt.length < 1) {
                    $('.messages').focus(); //自动获取焦点
                    return;
                }
                $.ajax({
                    type: "post",
                    url: "/Home/AddFwmb",
                    data: { mbid: zmbid, result: txt},
                    success: function (data) {
                        if (data.bl == true) {
                            $('.messages').html(''); // 清空输入框
                            showpage(3, 1);
                        } else {
                            console.log("转发失败");
                        }
                    },
                    error: function (err) {
                        console.log(err);
                    }
                })
            });
            var zmbid = 0;
            function getmbid(mbid,rid) {
                console.log(rid);
                zmbid = mbid;
                $.ajax({
                    type: "get",
                    url: "/Home/ZMric?rid=" + rid,
                    success: function (data) {
                        $("#zmicr").text(data);
                    }
                })
            }
        </script>
        @*回复*@
        <script type="text/javascript">
            //点击小图片，显示表情
            $("body").on('click', '.bq', function (e) {
                $(".face").slideDown(); //慢慢向下展开
                e.stopPropagation(); //阻止冒泡事件
            });
            //在桌面任意地方点击，关闭表情框
            $("body").on('click', document, function () {
                $(".face").slideUp(); //慢慢向上收
            });
            //点击小图标时，添加功能
            $("body").on('click', '.face ul li', function () {
                let simg = $(this).find("img").clone();
                $(".message").append(simg); //将表情添加到输入框
            });
            var reid = null;
            //点击发表按扭,评论该条微博
            $("body").on('click', 'span.submit', function () {
                var txt = $(".message").html(); //获取输入框内容
                if (txt.length < 1) {
                    $('.message').focus(); //自动获取焦点
                    return;
                }
                var mbid = $(".submit").attr("id");
                $.ajax({
                    type: "post",
                    url: "/Home/AddComm",
                    data: { mbid: mbid, result: txt, rid: reid },
                    success: function (data) {
                        $('.message').html(''); // 清空输入框
                        alert(data);

                    },
                    error: function (err) {
                        console.log(err);
                    }
                })
            });
           
            //回复评论
            function huiComm(rid,uid) {
                reid = rid;
                $.ajax({
                    type: "get",
                    url: "/Home/HuiComm",
                    data: { rid: rid, uid: uid },
                    success: function (data) {
                        $('.message').html(data);
                    }
                })
            }
            //删除当前数据
            function delComm(commid) {
                $.ajax({
                    type: "get",
                    url: "/Home/DelComm?commid=" + commid,
                    success: function (data) {
                        alert(data);
                    },
                    error: function (err) {
                        console.log(err);
                    }
                })
            }
        </script>
    </body>
    </html>
